﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Plane
{
    public partial class MainWindow: Form
    {
        private setting set;
        private Rank rank;

        private GameChoosing gamechoosing;
        private Shop shop;
        private (string Password, int Money, int HighestScore, int RecoveryAmount, int BulletAmount, string PlaneSkin, string KeyUp, string KeyDown, string KeyLeft, string KeyRight, string KeyFire, int SoundVolume) User;
        private MyPlane mp;

        private MyBullet mb;


        public MainWindow(string username)
        {
            InitializeComponent();
            User=UserDbHelper.GetUserInformationByUsername(username);
            // 去掉局部变量声明，直接给类的成员变量赋值
            set = new setting(this,User,username);
            rank = new Rank(this);

            gamechoosing = new GameChoosing(User.PlaneSkin,this,username);
            shop=new Shop(User,username);
            mp = new MyPlane(username);
            mb = new MyBullet(username);
            label_username.Text = "用户名："+username;
            label_money.Text = "金币数：" + User.Money;
            label_highestscore.Text = "最高得分：" + User.HighestScore;
        }

        // 多个按钮的展开和收起
        private bool isCollapsed = false;

        private void roundButton1_Click(object sender, EventArgs e)
        {
            if (isCollapsed)
            {
                panel1.Height = 270;
                ButtonRank.Visible = true;
                ButtonSetting.Visible = true;
                ButtonShop.Visible = true;
            }
            else
            {
                panel1.Height = 270;
                ButtonRank.Visible = false;
                ButtonSetting.Visible = false;
                ButtonShop.Visible = false;
            }
            isCollapsed = !isCollapsed;
        }

        private void ButtonBegin_Click(object sender, EventArgs e)
        {
            //this.DialogResult = DialogResult.OK;
            this.Hide();
            gamechoosing.Show();
            //gameform.Show();
        }

        private void ButtonSetting_Click(object sender, EventArgs e)
        {
            this.Hide();
            set.Show();
        }

        private void ButtonRank_Click(object sender, EventArgs e)
        {
            this.Hide();
            rank.Show();
        }

        private void ButtonShop_Click(object sender, EventArgs e)
        {
            this.Hide();
            shop.Show();
        }
    }
}
